﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Project.Model;
using EzDesk.Project.Service.Repositories.Interfaces;

namespace EzDesk.Project.Service.Repositories.Mock
{
    public class Mock_TaskRepository : Mock_Repository<Task>, ITaskRepository
    {
        public Guid TestPlaneId2_1 = new Guid("15B1D5BD-6C37-4D12-98E9-8C3BBFBFEEF9");
        public Guid TestPlaneId2_2 = new Guid("0516E47F-F36E-4AC2-A3B7-4FDA05EC53FF");
        public Guid TestPlaneId3_1 = new Guid("5F59996D-333C-468F-9739-B97778C84600");

        public Guid TestTaskId2_1_1 = new Guid("E69DCDD0-9059-41F5-A76C-C650EF7010B7");
        public Guid TestTaskId2_1_2 = new Guid("CA4E3926-3152-4A46-A83A-F832EFD94EB9");

        public Mock_TaskRepository()
        {
            if (!HasInitialized)
            {
                innerManager.ClearAll();
                innerManager.Add(new Task()
                {
                    Id = TestTaskId2_1_1,
                    Name = "第一个任务: 吃饭",
                    StartOn = DateTime.Parse("2010/5/4"),
                    EndOn = DateTime.Parse("2010/5/6"),
                    Director = innerManager.ApiClient.GetSimpleUserById(innerManager.SampleUsers["龚伟"]),
                    Description = "能吃多少吃多少",
                    ParentTaskId = TestPlaneId2_1,
                    IsClosed = false,
                }, true);
                innerManager.Add(new Task()
                {
                    Id = TestTaskId2_1_2,
                    Name = "第二个任务: 睡觉",
                    StartOn = DateTime.Parse("2010/5/5"),
                    EndOn = DateTime.Parse("2010/5/8"),
                    Director = innerManager.ApiClient.GetSimpleUserById(innerManager.SampleUsers["杨裕欣"]),
                    Description = "早睡早起身体好",
                    ParentTaskId = TestPlaneId2_1,
                    IsClosed = false,
                }, true);
            }
            base.Initialize();
        }

        public IList<Task> GetTasksByParentId(Guid parentId)
        {
            return innerManager.GetAll().Where(p => p.ParentTaskId == parentId).ToList();
        }
    }
}
